<?php

class Halls_EditAction extends SrsHallsBaseAction
{
	public function getCredentials()
	{
		return 'halls.edit';
	}

	public function executeRead(AgaviRequestDataHolder $rd)
	{
		return 'Input';
	}

	public function executeWrite(AgaviRequestDataHolder $rd)
	{
		$hallData = $rd->getParameter('hall');

		$hall = Doctrine_Query::create()
		        ->from('Hall')
			      ->where('id=?', $rd->getParameter('id'))
					  ->fetchOne();
		
		$hall->name     = $hallData['name'];
		$hall->address  = $hallData['address'];
		$hall->capacity = $hallData['capacity'];

		try
		{
			$hall->save();
		}
		catch (Exception $x)
		{
			return 'Error';
		}

		$this->setAttribute('hall', $hall->id);

		return 'Success';
	}
}